{%include file="index.header.tpl.php"%}
{%include file="index.left.tpl.php"%}
 <!--主要内容开始-->
<div class="content-wrapper">
    <section class="content">
        <div class="row">
            <section class="col-lg-12 connectedSortable">
                <div class="box box-default box-solid">
                    <form action="index.php?a=open.openadd" method="post">
                        <div class="box-header with-border">
                            <span class="fa fa-folder-open" style="float:left; font-size:18px; padding-top:3px; color:#3c8dbc;" ></span>
                            <p class="box-title">公开课安排表</p>
                        </div>
                        <div class="box-body">
                            <input type="button" class="btn btn-default" name="xx" onclick="addNewRow();" value="增加行"/>
                            <input type="button" class="btn btn-default" name="yy" onclick="removeRow();" value="删除行" />
                            <table class="table table-bordered"  id="myTab">
                                <tr>
                                    <td>选择</td>
                                    <td>周次</td>
                                    <td>教师</td>
                                    <td>日期</td>
                                    <td>节次</td>
                                    <td>班级</td>
                                    <td>教学内容</td>
                                    <td>科目</td>
                                    <td>备注</td>
                                </tr>
                            </table>
                        </div><!--box-body -->
                        <div class="box-footer text-center">
                            <button type="submit" class="btn btn-primary"> 保 存</button>
                        </div>
                    </form>
                </div><!--box box-default box-solid-->
            </section>

        </div><!--row-->
    </section>
</div>
  <!--主要内容结束-->
{%include file="index.footer.tpl.php"%}
 <script>
  $(function() {
    $( ".time" ).datepicker({
		 changeMonth: true,
	     changeYear: true,
		 dateFormat: "mm-dd",
    });
  });
  </script><script language="javascript">
//窗口表格增加一行
function addNewRow(){
var tabObj=document.getElementById("myTab");//获取添加数据的表格
var rowsNum = tabObj.rows.length;  //获取当前行数
var colsNum=tabObj.rows[rowsNum-1].cells.length;//获取行的列数
var myNewRow = tabObj.insertRow(rowsNum);//插入新行
var newTdObj1=myNewRow.insertCell(0);
newTdObj1.innerHTML="<input type='checkbox' name='chkArr' id='chkArr' "+rowsNum+" />";
var newTdObj2=myNewRow.insertCell(1);
newTdObj2.innerHTML="<input type='text' class='form-control' name='data["+rowsNum+"][open_week_num]' value='' size='3' />";
var newTdObj3=myNewRow.insertCell(2);
newTdObj3.innerHTML="<select class='form-control' style='padding:0px; width:100px;' name='data["+rowsNum+"][staff_id]'"+rowsNum+">" + "{%foreach from=$staff_list key=key item=value%}<option value='{%$value.staff_id%}'> {%$value.staff_name%}</option>{%/foreach%}</select>";
var newTdObj4=myNewRow.insertCell(3);
newTdObj4.innerHTML="<input type='text' class='form-control time' name='data["+rowsNum+"][open_time]' value=''/>";
var newTdObj5=myNewRow.insertCell(4);
newTdObj5.innerHTML="<input type='text' class='form-control' name='data["+rowsNum+"][open_num]' value='' size='4'/>";
var newTdObj6=myNewRow.insertCell(5);
newTdObj6.innerHTML="<select class='form-control' style='padding:0px; width:110px;'  name='data["+rowsNum+"][class_id]'"+rowsNum+" >{%foreach from=$class_list key=key item=value%} <option value='{%$value.class_id%}'>{%$value.class_name%}</option>{%/foreach%}</select>";
var newTdObj7=myNewRow.insertCell(6);
newTdObj7.innerHTML="<input type='text' name='data["+rowsNum+"][open_content]' class='form-control' value=''/>";
var newTdObj8=myNewRow.insertCell(7);
newTdObj8.innerHTML="<select class='form-control' name='data["+rowsNum+"][subject_id]' style='padding:0px; width:120px;' name='nodeper'"+rowsNum+" >{%foreach from=$subject_list key=key item=value%} <option value='{%$value.subject_id%}'>{%$value.subject_name%}</option>{%/foreach%}</select>";
var newTdObj9=myNewRow.insertCell(8);
newTdObj9.innerHTML="<textarea class='form-control' name='data["+rowsNum+"][open_remark]' rows='1'></textarea>";

$( ".time" ).datepicker({
changeMonth: true,
changeYear: true,
dateFormat: "yy-mm-dd",
});

}
//窗口表格删除一行
function removeRow(){
var chkObj=document.getElementsByName("chkArr");
var tabObj=document.getElementById("myTab");
for(var k=0;k<chkObj.length;k++){
if(chkObj[k].checked){
tabObj.deleteRow(k+1);
k=-1;
}
}
}
</script>